<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

	<head>
		<meta charset="utf-8">
		<title>新瑞途-编辑日志</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
        <link href="/static/css/bootstrap.min.css" rel="stylesheet" />
        <link href="/static/bower_components/font-awesome/css/font-awesome.css" rel="stylesheet" />
		<link href="/static/css/wxList.css" rel="stylesheet" />
		<link href="/static/css/wxListmin.css" rel="stylesheet" />
		<style>



            .footer_style1 {
				padding: 0 0 0 10px;
				font-size: 13px;
			}
			
			.footer_style1 span {
				float: left;
			}
			
			.ul_style3 {
				list-style: none;
				line-height: 20px;
				text-align: center;
				margin: 0;
				padding: 0;
				float: right;
				font-size: 13px;
			}
			
			.ul_style3 a {
				color: #333;
				text-decoration: none;
			}
			
			.ul_style3 a:HOVER {
				color: #15a4b5;
			}
			
			.ul_style3 li {
				float: left;
				padding: 0 5px 0 5px;
			}

            input[type=date]::-webkit-inner-spin-button{visibility: hidden;}

            #searchInput{
                float: left;
            }
            .searchBtn{
                margin-left: 3px;
                width: 70px;
                height: 40px;
                font-size: 16px;
                font-family: 'Helvetica Neue';
                background-color: #20c997;
                color: #F9F9F9;
                float: right;
            }

            #addBtn{
                float: right;
            }
            #seaBtn{
                float: right;
            }

            input.es-input { padding-right: 20px !important; background: url() right center no-repeat; }
            input.es-input.open {
                -webkit-border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; border-bottom-left-radius: 0;
                -webkit-border-bottom-right-radius: 0; -moz-border-radius-bottomright: 0; border-bottom-right-radius: 0; }
            .es-list { position: absolute; padding: 0; margin: 0; border: 1px solid #d1d1d1; display: none; z-index: 1000; background: #fff; max-height: 160px; overflow-y: auto;
                -moz-box-shadow: 0 2px 3px #ccc; -webkit-box-shadow: 0 2px 3px #ccc; box-shadow: 0 2px 3px #ccc; }
            .es-list li { display: block; padding: 5px 10px; margin: 0; }
            .es-list li.selected { background: #f3f3f3; }
            .es-list li[disabled] { opacity: .5; }



		</style>
	</head>

	<body>


            <div class="modal-dialog">
                <div class="modal-content">

                    <div id="form1" class="modal-body">
                        <form class="form-horizontal"  role="form">
                            <input type="hidden" id="url" name="url" />
                            <input type="hidden" id="id" name="id" th:value="${ReEditLog.id}" />
                            <div class="form-group">
                                <label for="prj_name" class="col-sm-2 control-label">项目名称</label>
                                <div class="col-sm-10">
                                    <select id="prj_name" name="prj_name" th:value="${ReEditLog.prj_name}" class="form-control" placeholder="请输入或选择项目名称">
                                        <option th:each="carpj,userStat:${WxPrjNameList}" th:value="${carpj.prj_name}" th:text="${carpj.prj_name}"></option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="prj_name_2nd" class="col-sm-2 control-label">二级名称</label>
                                <div class="col-sm-10">
                                    <select id="prj_name_2nd" name="prj_name_2nd" th:value="${ReEditLog.prj_name_2nd}" class="form-control" placeholder="请输入或选择二级名称">
                                        <option th:each="carpj2,userStat:${WxPrj2ndNameList}" th:value="${carpj2.prj_name_2nd}" th:text="${carpj2.prj_name_2nd}"></option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="drawing_no" class="col-sm-2 control-label">图号</label>
                                <div class="col-sm-10">
                                    <select id="drawing_no" name="drawing_no" th:value="${ReEditLog.drawing_no}" onblur="dnChange();" class="form-control" placeholder="请输入或选择图号">
                                        <option th:each="car,userStat:${WxDrawNoList}" th:value="${car.drawing_no}" th:text="${car.drawing_no}"></option>
                                    </select>
                                </div>
                            </div>

                            <!--<div class="form-group">
                                <label for="ac_name" class="col-sm-2 control-label">名称</label>
                                <div class="col-sm-10">
                                    <select id="ac_name" name="ac_name" th:value="${ReEditLog.ac_name}" onblur="anChange();" class="form-control" placeholder="请输入或选择名称">
                                        <option th:each="cart,userStat:${WxAcNameList}" th:value="${cart.ac_name}" th:text="${cart.ac_name}"></option>
                                    </select>
                                </div>
                            </div>-->

                            <div class="form-group">
                                <label for="part_no" class="col-sm-2 control-label">件号</label>
                                <div class="col-sm-10">
                                    <select id="part_no" name="part_no" th:value="${ReEditLog.part_no}" onblur="pnoChange();" class="form-control" placeholder="请输入或选择件号">
                                        <option th:each="cartt,userStat:${WxPartNoList}" th:value="${cartt.part_no}" th:text="${cartt.part_no}"></option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="process_type" class="col-sm-2 control-label">工序</label>
                                <div class="col-sm-10">
                                    <select id="process_type" name="process_type" th:value="${ReEditLog.process_type}" onblur="ptChange();" class="form-control" placeholder="请选择工序">
                                        <!--<option value="">请选择</option>-->
                                        <option>拼接板钻孔</option>
                                        <option>杆件钻孔</option>
                                        <option>磁力钻钻孔</option>
                                        <option>刨边</option>
                                        <option>焰切</option>
                                        <option>其他一</option>
                                        <option>其他二</option>
                                        <option>其他三</option>
                                        <option>其他四</option>
                                        <option>其他五</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="count" class="col-sm-2 control-label">数量</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="count" th:value="${ReEditLog.count}" value="" id="count" placeholder="请输入数量">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="thickness" class="col-sm-2 control-label">厚度</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="thickness" th:value="${ReEditLog.thickness}" value="" id="thickness" placeholder="请输入厚度">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="height" class="col-sm-2 control-label">宽度</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="height" th:value="${ReEditLog.height}" value="" id="height" placeholder="请输入宽度">
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="width" class="col-sm-2 control-label">长度</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="width" th:value="${ReEditLog.width}" value="" id="width" placeholder="请输入宽度">
                                </div>
                            </div>

                            <div class="form-group" id="single_weight_div">
                                <label for="single_weight" class="col-sm-2 control-label">单件重量</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="single_weight" th:value="${ReEditLog.single_weight}" value="" id="single_weight" placeholder="请输入单件重量">
                                </div>
                            </div>

                            <div class="form-group" id="single_hole_div">
                                <label for="single_hole" class="col-sm-2 control-label" id="holeText">单件孔数</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="single_hole" th:value="${ReEditLog.single_hole}" value="" id="single_hole" placeholder="请输入单件孔数">
                                </div>
                            </div>

                            <div class="form-group" id="single_length_div">
                                <label for="single_length" class="col-sm-2 control-label">单件长度</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="single_length" th:value="${ReEditLog.single_length}" value="" id="single_length" readonly>
                                </div>
                            </div>


                            <div class="form-group">
                                <label for="coefficient" class="col-sm-2 control-label">系数</label>
                                <div class="col-sm-10">
                                    <input type="number" class="form-control" name="coefficient" th:value="${ReEditLog.coefficient}" value="" id="coefficient" placeholder="请输入系数">
                                </div>
                            </div>

                           <!-- <div class="form-group" id="replyDiv">
                                <label for="coefficient" class="col-sm-2 control-label">批复</label>
                                <div class="col-sm-10">
                                    <textarea class="form-control" name="reply" value="" id="reply" rows="3" readonly></textarea>
                                </div>
                            </div>-->
                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-warning" onclick="goBack()">返回</button>
                        <button type="submit" class="btn btn-info" onclick="saveLog()"  id="imgSubmit">保存</button>
                       <!-- <button class="btn btn-success" id="subBtn" onclick="subLog();"  hidden>提交</button>-->
                    </div>
                </div>
            </div>

	</body>
    <script src="/static/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="/static/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="/static/dist/js/adminlte.min.js"></script>
    <script src="/static/js/jquery-editable-select.js"></script>
<script>

    $('#prj_name').editableSelect({
        effects: 'slide'
    });
    $('#prj_name_2nd').editableSelect({
        effects: 'slide'
    });
    $('#drawing_no').editableSelect({
        effects: 'slide'
    });
    $('#ac_name').editableSelect({
        effects: 'slide'
    })
    $('#part_no').editableSelect({
        effects: 'slide'
    });
    $('#process_type').editableSelect({
        effects: 'slide'
    });

    $('#prj_name_search').editableSelect({
        effects: 'slide'
    });
    $('#prj_name_2nd_search').editableSelect({
        effects: 'slide'
    });
    $('#process_type_search').editableSelect({
        effects: 'slide'
    });
    $('#status_search').editableSelect({
        effects: 'slide'
    });

    $(function () {
        var model_process_type = "[[${ReEditLog.process_type}]]";
        if(model_process_type == "刨边"){
            $("#single_weight_div").show();
            $("#single_hole_div").hide();
            $("#single_length_div").hide();
        }
        if(model_process_type == "拼接板钻孔" || model_process_type == "杆件钻孔" || model_process_type == "磁力钻钻孔"
            || model_process_type == "其他一" || model_process_type == "其他二" || model_process_type == "其他三" || model_process_type == "其他四" || model_process_type == "其他五"){
            $("#single_weight_div").hide();
            $("#single_hole_div").show();
            $("#single_length_div").hide();
        }
        /*if(model_process_type == "拼接板钻孔" || model_process_type == "杆件钻孔" || model_process_type == "磁力钻钻孔"){
            $("#holeText").text("单件孔数");
        }
        if(model_process_type == "其他一" || model_process_type == "其他二" || model_process_type == "其他三" || model_process_type == "其他四" || model_process_type == "其他五"){
            $("#holeText").text("单件数量");
        }*/

        if(model_process_type == "焰切"){
            $("#single_weight_div").hide();
            $("#single_hole_div").hide();
            $("#single_length_div").show();
        }
    });


    // 验证图号、名称、件号所选的值,获取长、宽、厚
    function getTHWValue(drawing_no,part_no) {
        $.ajax({
            type:"GET",
            url:"/wx/getTHWValue",
            cache:false,
            dataType:"json",
            data:{
                drawing_no:drawing_no,
                part_no:part_no
            },
            success:function(data){
                if(data.status == "success"){
                    var obj = data.data;
                    if(null != obj){
                        $("#thickness").val(obj.thickness);
                        $("#height").val(obj.height);
                        $("#width").val(obj.width);
                    } else {
                        $("#thickness").val("");
                        $("#height").val("");
                        $("#width").val("");
                    }
                }else{
                    alert(data.msg);
                }
            }
        });
    }

    // 选择图号、名称、件号触发
    function dnChange() {
        var drawing_no = $("#drawing_no").val();
        //var ac_name = $("#ac_name").val();
        var part_no = $("#part_no").val();
        if(null != drawing_no && drawing_no != "" &&  null != part_no && part_no != ""){
            getTHWValue(drawing_no,part_no);
        }
    }
    function anChange() {
        var drawing_no = $("#drawing_no").val();
        var ac_name = $("#ac_name").val();
        var part_no = $("#part_no").val();
        if(null != drawing_no && drawing_no != "" && null != ac_name && ac_name != "" && null != part_no && part_no != ""){
            getTHWValue(drawing_no,ac_name,part_no);
        }
    }
    function pnoChange() {
        var drawing_no = $("#drawing_no").val();
        //var ac_name = $("#ac_name").val();
        var part_no = $("#part_no").val();
        if(null != drawing_no && drawing_no != "" && null != part_no && part_no != ""){
            getTHWValue(drawing_no,part_no);
        }
    }

    // 选择工序时触发
    function ptChange() {
        var process_type = $("#process_type").val();
        if(process_type == "刨边"){
            $("#single_weight_div").show();
            $("#single_hole_div").hide();
            $("#single_length_div").hide();
        }
        if(process_type == "拼接板钻孔" || process_type == "杆件钻孔" || process_type == "磁力钻钻孔"
            || process_type == "其他一" || process_type == "其他二" || process_type == "其他三" || process_type == "其他四" || process_type == "其他五"){
            $("#single_weight_div").hide();
            $("#single_hole_div").show();
            $("#single_length_div").hide();
        }
       /* if(process_type == "拼接板钻孔" || process_type == "杆件钻孔" || process_type == "磁力钻钻孔"){
            $("#holeText").text("单件孔数");
        }
        if(process_type == "其他一" || process_type == "其他二" || process_type == "其他三" || process_type == "其他四" || process_type == "其他五"){
            $("#holeText").text("单件数量");
        }*/

        if(process_type == "焰切"){
            $("#single_weight_div").hide();
            $("#single_hole_div").hide();
            $("#single_length_div").show();
        }
    }


    //点击保存按钮触发
    function saveLog() {
        
        //alert(999);
        var id = $("input[name='id']").val();
        var prj_name = $("#prj_name").val();
        var prj_name_2nd = $("#prj_name_2nd").val();
        var drawing_no = $("#drawing_no").val();
        //var ac_name = $("#ac_name").val();
        var part_no = $("#part_no").val();
        var process_type = $("#process_type").val();
        var count = $("input[name='count']").val();
        var thickness = $("input[name='thickness']").val();
        var height = $("input[name='height']").val();
        var width = $("input[name='width']").val();
        var single_weight = $("input[name='single_weight']").val();
        var single_hole = $("input[name='single_hole']").val();
        var single_length;
        var coefficient = $("input[name='coefficient']").val();


        if(null == prj_name || prj_name == ""){
            alert("项目名称不能为空");
            return false;
        }
        if(null == count || count == ""){
            alert("数量不能为空");
            return false;
        }
        if(null == coefficient || coefficient == ""){
            alert("系数不能为空");
            return false;
        }

        if(process_type != "拼接板钻孔" && process_type != "杆件钻孔" && process_type != "磁力钻钻孔" && process_type != "刨边" && process_type != "焰切"
            && process_type != "其他一" && process_type != "其他二" && process_type != "其他三" && process_type != "其他四" && process_type != "其他五"){
            alert("请选择正确的工序");
            return false;
        }

        if(process_type == "焰切"){
            single_length = (parseFloat(height) + parseFloat(width)) * 2;
            $("#single_length").val(single_length);
        }

        $.ajax({
            type:"post",
            url:"/wx/editLog",
            cache:false,
            dataType:"json",
            data:{
                id:id,
                prj_name:prj_name,
                prj_name_2nd:prj_name_2nd,
                drawing_no:drawing_no,
                part_no:part_no,
                process_type:process_type,
                count:count,
                thickness:thickness,
                height:height,
                width:width,
                single_weight:single_weight,
                single_hole:single_hole,
                single_length:single_length,
                coefficient:coefficient
            },
            success:function(data){
                if(data.status == 'success'){
                    location.href = "/wx/toAdminList"
                }else{
                    alert(data.msg);
                }
            }
        });
    }

    // 点击返回触发
    function  goBack() {
        location.href = "/wx/goBackAdminList"
    }


</script>

</html>